<template>
	<el-container style="height:96%">
		<div>
			<!-- 搜索栏 -->
			<el-row>
				<el-form
					v-show="showSearch"
					ref="queryForm"
					:model="queryParams"
					:inline="true"
					label-width="68px"
				>
					<el-form-item label="业务名称" prop="name">
						<el-input
							v-model="queryParams.name"
							placeholder="请输入业务名称"
							clearable
							size="small"
							@keyup.enter.native="handleQuery"
						/>
					</el-form-item>
					<!-- 登录名 -->
					<el-form-item label="登录名" prop="loginName">
						<el-input
							v-model="queryParams.loginName"
							placeholder="请输入登录名"
							clearable
							size="small"
							@keyup.enter.native="handleQuery"
						/>
					</el-form-item>
					<!-- 所属机构 -->
					<el-form-item label="搜索设备" prop="deviceCode">
						<el-select
							v-model="queryParams.deviceCode"
							placeholder="请选择"
							filterable
							@keyup.enter.native="handleQuery"
							clearable
						>
							<el-option
								v-for="item in deviceList"
								:key="item.code"
								:label="item.name"
								:value="item.code"
							>
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item :label="$t('program.status')" prop="status">
						<el-select
							v-model="queryParams.status"
							:placeholder="$t('equipment.statusSelect')"
							clearable
							size="small"
						>
							<el-option
								v-for="dict in statusOptions"
								:key="dict.value"
								:label="dict.label"
								:value="dict.value"
							/>
						</el-select>
					</el-form-item>
					<el-form-item :label="$t('elButton.establishTime')">
						<el-date-picker
							v-model="dateRange"
							size="small"
							style="width: 240px"
							value-format="yyyy-MM-dd"
							type="daterange"
							range-separator="-"
							:start-placeholder="$t('elButton.startTime')"
							:end-placeholder="$t('elButton.endTime')"
						/>
					</el-form-item>
					<el-form-item>
						<el-button
							type="primary"
							icon="el-icon-search"
							size="mini"
							@click="handleQuery"
							>{{ $t('elButton.search') }}
						</el-button>
						<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{
							$t('elButton.reset')
						}}</el-button>
					</el-form-item>
				</el-form>
			</el-row>
			<!-- 工具栏 -->
			<el-row :gutter="10" class="mb8">
				<el-col :span="1.5">
					<!-- <el-button
						v-hasPerm="['bizinfo_add']"
						type="primary"
						icon="el-icon-plus"
						size="mini"
						@click="handleAdd"
						>{{ $t('elButton.add') }}
					</el-button> -->
					<el-dropdown split-button type="primary" @command="handleCommand">
						下拉新增
						<el-dropdown-menu slot="dropdown">
							<el-dropdown-item command="first">一级业务</el-dropdown-item>
							<el-dropdown-item command="second">二级业务</el-dropdown-item>
						</el-dropdown-menu>
					</el-dropdown>
				</el-col>
				<!-- <el-col :span="1.5">
					<el-button
						v-hasPerm="['bizinfo_edit']"
						type="success"
						icon="el-icon-edit"
						size="mini"
						:disabled="single"
						@click="handleEdit"
						>{{ $t('elButton.change') }}
					</el-button>
				</el-col> -->
				<!-- 删除 -->
				<el-col :span="1.5">
					<el-button
						v-hasPerm="['bizinfo_del']"
						type="danger"
						icon="el-icon-delete"
						size="mini"
						:disabled="multiple"
						@click="handleDel"
						>{{ $t('elButton.delete') }}
					</el-button>
				</el-col>
				<!-- <el-col :span="1.5">
					<el-button
						v-hasPerm="['bizinfo_export']"
						type="warning"
						icon="el-icon-download"
						size="mini"
						@click="handleExport"
						>{{ $t('elButton.export') }}
					</el-button>
				</el-col> -->
				<el-col :span="1.5">
					<el-button
						v-hasPerm="['bizinfo_edit']"
						type="success"
						size="mini"
						@click="handleCache"
					>
						<el-tooltip
							:content="$t('calling.updateCacheContent')"
							placement="top"
						>
							<i class="el-icon-question" />
						</el-tooltip>
						{{ $t('calling.updateCache') }}
					</el-button>
				</el-col>
				<el-col :span="1.5">
					<!-- 统一规则 -->
					<el-button
						v-hasPerm="['bizinfo_edit']"
						type="success"
						size="mini"
						@click="uniformRules"
					>
						{{ '统一规则' }}
					</el-button>
				</el-col>
				<div class="top-right-btn">
					<el-tooltip
						class="item"
						effect="dark"
						:content="$t('elButton.refresh')"
						placement="top"
					>
						<el-button
							size="mini"
							circle
							icon="el-icon-refresh"
							@click="handleQuery"
						/>
					</el-tooltip>
					<el-tooltip
						class="item"
						effect="dark"
						:content="
							showSearch ? $t('elButton.hideSearch') : $t('elButton.showSearch')
						"
						placement="top"
					>
						<el-button
							size="mini"
							circle
							icon="el-icon-search"
							@click="showSearch = !showSearch"
						/>
					</el-tooltip>
				</div>
			</el-row>
		</div>
		<el-main>
			<!-- 中间表格数据 -->
			<el-table
				v-loading="loading"
				:data="bizinfoList"
				:row-key="getRowKeys"
				@selection-change="handleSelectionChange"
				:tree-props="{ children: 'counterList', hasChildren: 'hasChildren' }"
			>
				<el-table-column type="selection" width="55" align="center" />
				<el-table-column label="序号" type="index" width="50">
				</el-table-column>

				<el-table-column
					:label="$t('equipment.number')"
					align="center"
					prop="id"
				/>
				<el-table-column label="业务名称" align="center" prop="name" />
				<el-table-column label="登录名" align="center" prop="loginName" />
				<el-table-column label="最后登录时间" align="center" prop="loginTime">
					<template slot-scope="scope">
						<span>{{ parseTime(scope.row.loginTime) }}</span>
					</template></el-table-column
				>
				<el-table-column
					label="状态"
					align="center"
					prop="status"
					:formatter="statusFormat"
				/>
				<el-table-column label="所属机构" align="center" prop="deptName" />
				<el-table-column label="语音模板" align="center" prop="voiceName" />
				<!-- <el-table-column label="创建时间" align="center" prop="createTime" /> -->
				<!-- <el-table-column
				:label="$t('calling.style')"
				align="center"
				prop="isAutoReport"
				:formatter="typeFormat"
			/>
			<el-table-column
				:label="$t('program.status')"
				align="center"
				prop="status"
				:formatter="statusFormat"
			/> -->
				<el-table-column label="创建时间" align="center" prop="createTime">
					<template slot-scope="scope">
						<span>{{ parseTime(scope.row.createTime) }}</span>
					</template>
				</el-table-column>
				<el-table-column
					:label="$t('equipment.control')"
					align="center"
					class-name="small-padding fixed-width"
					width="200"
					fixed="right"
				>
					<template slot-scope="scope">
						<el-button
							v-hasPerm="['bizinfo_rule']"
							size="mini"
							type="text"
							icon="el-icon"
							@click="handleBizInfoRule(scope.row)"
							>{{ $t('calling.rule') }}
						</el-button>
						<el-button
							v-hasPerm="['bizinfo_edit']"
							size="mini"
							type="text"
							icon="el-icon-edit"
							@click="handleEdit(scope.row)"
							>{{ $t('elButton.change') }}
						</el-button>
						<el-button
							v-hasPerm="['bizinfo_del']"
							size="mini"
							type="text"
							icon="el-icon-delete"
							@click="handleDel(scope.row)"
							>{{ $t('elButton.delete') }}
						</el-button>
					</template>
				</el-table-column>
			</el-table></el-main
		>
		<el-footer>
			<pagination
				v-show="total > 0"
				:total="total"
				:page.sync="queryParams.current"
				:limit.sync="queryParams.size"
				@pagination="getList"
		/></el-footer>
		<!--门诊规则列表-->
		<el-dialog
			:title="title"
			:visible.sync="openBizInfoRule"
			:modal-append-to-body="true"
			:append-to-body="true"
			width="60%"
		>
			<el-row :gutter="10" class="mb8">
				<el-col :span="1.5">
					<el-button
						v-hasPerm="['bizinfo_rule_add']"
						type="primary"
						icon="el-icon-plus"
						size="mini"
						@click="handleBizInfoRuleAdd()"
						>{{ $t('elButton.add') }}
					</el-button>
				</el-col>
				<div class="top-right-btn">
					<el-tooltip
						class="item"
						effect="dark"
						:content="$t('elButton.refresh')"
						placement="top"
					>
						<el-button
							size="mini"
							circle
							icon="el-icon-refresh"
							@click="getBizInfoRuleList(bizinfoId)"
						/>
					</el-tooltip>
				</div>
			</el-row>
			<el-table
				v-loading="loading"
				:data="bizinfoRuleList"
				@selection-change="handleSelectionChange"
			>
				<el-table-column
					:label="$t('equipment.number')"
					width="55"
					align="center"
					prop="id"
				/>
				<el-table-column
					:label="$t('calling.number')"
					align="center"
					prop="num"
				/>
				<el-table-column
					align="center"
					prop="isAutoReport"
					:label="$t('calling.isAutoReport')"
					width="150"
					:formatter="isAutoReportFormat"
				/>
				<el-table-column
					:label="$t('program.status')"
					align="center"
					prop="status"
					:formatter="statusRuleFormat"
				/>
				<el-table-column
					:label="$t('calling.reportWay')"
					align="center"
					prop="reportWay"
					:formatter="reportWayFormat"
				/>
				<el-table-column
					:label="$t('equipment.remarks')"
					align="center"
					prop="remarks"
					:show-overflow-tooltip="true"
				/>
				<el-table-column
					:label="$t('equipment.control')"
					align="center"
					class-name="small-padding fixed-width"
				>
					<template slot-scope="scope">
						<el-button
							v-hasPerm="['bizinfo_rule_status_update']"
							size="mini"
							type="text"
							@click="handleBizInfoRuleStatusEdit(scope.row)"
						>
							<span v-if="scope.row.status == 0" style="color:red">{{
								$t('elButton.Disable')
							}}</span>
							<span v-if="scope.row.status == 1">{{
								$t('elButton.Enable')
							}}</span>
						</el-button>
						<el-button
							v-hasPerm="['bizinfo_rule_edit']"
							size="mini"
							type="text"
							icon="el-icon-edit"
							@click="handleBizInfoRuleEdit(scope.row)"
							>{{ $t('elButton.change') }}
						</el-button>
						<el-button
							v-hasPerm="['bizinfo_rule_del']"
							size="mini"
							type="text"
							icon="el-icon-delete"
							@click="handleBizInfoRuleDel(scope.row)"
							>{{ $t('elButton.delete') }}
						</el-button>
					</template>
				</el-table-column>
			</el-table>
		</el-dialog>
		<!--诊室规则列表-->
		<el-dialog
			:title="title"
			:visible.sync="openCounterRule"
			:modal-append-to-body="true"
			:append-to-body="true"
			width="60%"
		>
			<el-row :gutter="10" class="mb8">
				<el-col :span="1.5">
					<el-button
						v-hasPerm="['counter_rule_add']"
						type="primary"
						icon="el-icon-plus"
						size="mini"
						@click="handleCounterRuleAdd"
						>{{ $t('elButton.add') }}
					</el-button>
				</el-col>
				<div class="top-right-btn">
					<el-tooltip
						class="item"
						effect="dark"
						:content="$t('elButton.refresh')"
						placement="top"
					>
						<el-button
							size="mini"
							circle
							icon="el-icon-refresh"
							@click="getCounterRuleList(counterId)"
						/>
					</el-tooltip>
				</div>
			</el-row>
			<el-table
				v-loading="loading"
				:data="counterRuleList"
				@selection-change="handleSelectionChange"
			>
				<el-table-column
					:label="$t('equipment.number')"
					width="55"
					align="center"
					prop="id"
				/>
				<el-table-column
					:label="$t('calling.style')"
					align="center"
					prop="type"
					:show-overflow-tooltip="true"
					:formatter="typeFormat"
				/>
				<el-table-column
					:label="$t('program.status')"
					align="center"
					prop="status"
					:formatter="statusRuleFormat"
				/>
				<el-table-column
					:label="$t('calling.number')"
					align="center"
					prop="num"
					:show-overflow-tooltip="true"
				/>
				<el-table-column
					:label="$t('equipment.control')"
					align="center"
					class-name="small-padding fixed-width"
				>
					<template slot-scope="scope">
						<el-button
							v-hasPerm="['bizinfo_rule_status_edit']"
							size="mini"
							type="text"
							@click="handleBizInfoRuleStatusEdit(scope.row)"
						>
							<span v-if="scope.row.status == 0" style="color:red">{{
								$t('elButton.Disable')
							}}</span>
							<span v-if="scope.row.status == 1">{{
								$t('elButton.Enable')
							}}</span>
						</el-button>
						<el-button
							v-hasPerm="['counter_rule_edit']"
							size="mini"
							type="text"
							icon="el-icon-edit"
							@click="handleCounterRuleEdit(scope.row)"
							>{{ $t('elButton.change') }}
						</el-button>
						<el-button
							v-hasPerm="['counter_rule_del']"
							size="mini"
							type="text"
							icon="el-icon-delete"
							@click="handleCounterRuleDel(scope.row)"
							>{{ $t('elButton.delete') }}
						</el-button>
					</template>
				</el-table-column>
			</el-table>
		</el-dialog>
		<!--门诊规则新增修改-->
		<el-dialog
			:title="title"
			:visible.sync="openBizInfoRuleAdd"
			:modal-append-to-body="true"
			:append-to-body="true"
			:before-close="cancelBizInfoRule"
		>
			<el-form ref="form" :model="form" :rules="rules" label-width="80px">
				<span style="color:#909399">{{ $t('calling.basicConfigure') }}</span>
				<el-divider></el-divider>
				<el-row>
					<el-col :span="12" v-if="isuniformRules">
						<el-form-item label="科室">
							<SelectAll
								v-model="form.bizinfoIdList"
								:valueKey="'id'"
								:labelKey="'name'"
								:options="bizinfoOptions"
							></SelectAll>
						</el-form-item>
					</el-col>
					<el-col :span="12" v-else>
						<el-form-item :label="$t('program.status')">
							<el-radio-group v-model="form.status">
								<el-radio
									v-for="dict in [
										{ label: $t('calling.bizinfoRuleStatusEnable'), value: 0 },
										{ label: $t('calling.bizinfoRuleStatusDisable'), value: 1 },
									]"
									:key="dict.value"
									:label="dict.value"
									>{{ dict.label }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item
							:label="$t('calling.isAutoReport')"
							prop="isAutoReport"
						>
							<el-radio-group v-model="form.isAutoReport">
								<el-radio
									v-for="dict in [
										{ label: $t('yes'), value: 1 },
										{ label: $t('no'), value: 2 },
									]"
									:key="dict.value"
									:label="dict.value"
									>{{ dict.label }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item
							style="width: 60%"
							:label="$t('calling.queueBinding')"
							prop="isFollowStaff"
						>
							<el-radio-group v-model="form.isFollowStaff">
								<el-radio
									v-for="dict in [
										{ label: '用户账户', value: 1 },
										{ label: '诊室/窗口', value: 2 },
									]"
									:key="dict.value"
									:label="dict.value"
									>{{ dict.label }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item
							style="width: 60%"
							:label="$t('calling.ticketStyle')"
							prop="ticketStyle"
						>
							<el-select
								v-model="form.ticketStyle"
								:placeholder="$t('calling.ticketStyle')"
								style="width: 100%;"
							>
								<el-option
									v-for="item in ticketStyleList"
									:key="item.value"
									:label="item.label"
									:value="item.value"
								/>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item
							:label="$t('calling.ticketFormat')"
							prop="ticketFormat"
						>
							<el-input
								style="width: 35%"
								v-model="form.ticketHead"
								:placeholder="$t('calling.ticketHead')"
							>
							</el-input>
							<el-tag style="width:30%" type="info">
								{{
									ticketStyleList[form.ticketStyle - 1] == null
										? null
										: ticketStyleList[form.ticketStyle - 1].label
								}}
							</el-tag>
							<!--              <input type="submit" style="border-right: 0px" value="Submit" />-->
							<el-input
								style="width: 35%;"
								v-model="form.ticketEnd"
								:placeholder="$t('calling.ticketEnd')"
							></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="10">
						<el-form-item :label="$t('calling.isReport')" prop="isReport">
							<el-radio-group v-model="form.isReport">
								<el-radio
									v-for="dict in [
										{ label: $t('yes'), value: 1 },
										{ label: $t('no'), value: 2 },
									]"
									:key="dict.value"
									:label="dict.value"
									>{{ dict.label }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
					<el-col v-if="form.isReport === 2" :offset="2" :span="12">
						<el-form-item
							labelWidth="100px"
							:label="$t('calling.reportInterval')"
							prop="ticketFormat"
						>
							<el-input-number
								:min="0"
								v-model="form.reportInterval"
								:label="$t('calling.reportInterval')"
							>
							</el-input-number>
							<span style="padding-left: 4px">min</span>
						</el-form-item>
					</el-col>
					<el-col v-if="form.isReport === 2" :span="20">
						<el-form-item
							size=""
							labelWidth="100px"
							:label="$t('calling.repeatJudge')"
							prop="repeatJudge"
						>
							<el-select
								size="medium"
								v-model="repeatJudge"
								multiple
								:placeholder="$t('calling.repeatJudge')"
							>
								<el-option
									v-for="item in [
										{ label: $t('calling.idCard'), value: '1' },
										{ label: $t('calling.medicalInsurance'), value: '2' },
										{ label: $t('calling.MedicalCard'), value: '3' },
									]"
									:key="item.value"
									:label="item.label"
									:value="item.value"
								/>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item
							labelWidth="100px"
							:label="$t('calling.timeInterval')"
						>
							<!--              <el-time-picker v-for="(item, index)  in intervalTimes"-->
							<!--                              is-range-->
							<!--                              v-model="intervalTimes[index]"-->
							<!--                              format="HH:mm"-->
							<!--                              :clearable="false"-->
							<!--                              :editable="false"-->
							<!--                              range-separator="至"-->
							<!--                              :start-placeholder="$t('calling.startTime')"-->
							<!--                              :end-placeholder="$t('calling.finishTime')"-->
							<!--                              :placeholder="$t('calling.timeInterval')"-->
							<!--              >-->
							<!--              </el-time-picker>-->
							<el-button
								type="text"
								icon="el-icon-plus"
								style="width: 100%"
								v-show="isAddable(-1)"
								:disabled="!isAddable(-1)"
								@click="addItem(-1)"
							></el-button>
							<div v-for="(item, index) in intervalTimes" :key="index">
								<ScheduleGroupItem
									v-model="intervalTimes[index]"
									:max-time="getMaxTime(index)"
									:min-time="getMinTime(index)"
									:addable="isAddable(index)"
									@add="addItem(index)"
									@delete="deleteItem(index)"
								>
								</ScheduleGroupItem>
							</div>
							<!--              <i style="padding-left: 3px" class="el-icon-circle-plus" @click="addIntervalTime"></i>-->
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item :label="$t('calling.repeatCycle')">
							<el-checkbox-group size="mini" v-model="repeatCycle">
								<el-checkbox
									v-for="city in [
										{ label: $t('calling.Monday'), value: '1' },
										{ label: $t('calling.Tuesday'), value: '2' },
										{ label: $t('calling.Wednesday'), value: '3' },
										{ label: $t('calling.Thursday'), value: '4' },
										{ label: $t('calling.Friday'), value: '5' },
										{ label: $t('calling.Saturday'), value: '6' },
										{ label: $t('calling.Sunday'), value: '7' },
									]"
									:label="city.value"
									:key="city.value"
									>{{ city.label }}
								</el-checkbox>
								<br />
								<el-checkbox
									v-model="form.skipHoliday"
									:label="$t('calling.skipHoliday')"
								>
								</el-checkbox>
							</el-checkbox-group>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<span style="color:#909399">{{ $t('calling.queueRule') }}</span>
					<el-divider></el-divider>
					<el-col :span="20">
						<el-form-item :label="$t('calling.limitNumber')" prop="num">
							<el-input-number v-model="form.num" :min="1" />
						</el-form-item>
					</el-col>
					<!--          <el-col :span="8">-->
					<!--            <el-form-item :label="$t('calling.isAutoEliminate')" prop="isAutoReport">-->
					<!--              <el-radio-group v-model="form.isAutoEliminate">-->
					<!--                <el-radio-->
					<!--                    v-for="dict in [{label:$t('yes'),value:1},{label:$t('no'),value:2}]"-->
					<!--                    :key="dict.value"-->
					<!--                    :label="dict.value"-->
					<!--                >{{ dict.label }}-->
					<!--                </el-radio>-->
					<!--              </el-radio-group>-->
					<!--            </el-form-item>-->
					<!--          </el-col>-->
					<el-col :span="24">
						<el-form-item :label="$t('calling.reportWay')" prop="reportWay">
							<el-select
								v-model="form.reportWay"
								:placeholder="$t('calling.reportWay')"
								style="width: 25%;"
							>
								<el-option
									v-for="item in [
										{ label: $t('calling.reportWayStatus'), value: 1 },
										{ label: $t('calling.reportWayStatusAverage'), value: 3 },
										{ label: $t('calling.reportWayStatusCross'), value: 4 },
										{ label: $t('calling.reportWayStatusRatio'), value: 5 },
										{ label: '不分配', value: 6 },
									]"
									:key="item.value"
									:label="item.label"
									:value="item.value"
								/>
							</el-select>
						</el-form-item>
					</el-col>

					<el-col
						v-if="form.isAutoReport === 1 && form.reportWay == 4"
						:span="24"
					>
						<el-form-item :label="$t('calling.crossType')">
							<el-radio-group v-model="form.crossType">
								<el-radio :label="0">{{
									$t('calling.oddBeforeEven')
								}}</el-radio>
								<el-radio :label="1">{{
									$t('calling.EvenBeforeOdd')
								}}</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
					<el-col
						v-if="form.reportWay === 5 && form.isAutoReport === 1"
						v-for="item in counterNumList"
						:key="item.id"
						:span="6"
					>
						<el-form-item label-width="100px" :label="item.name" prop="maxNum">
							<el-input-number v-model="item.num" precision="0" :min="0" />
						</el-form-item>
					</el-col>

					<el-col :span="20">
						<el-form-item
							:label="$t('calling.eliminateWay')"
							prop="eliminateWay"
						>
							<el-select
								v-model="form.eliminateWay"
								:placeholder="$t('calling.eliminateWay')"
							>
								<el-option
									v-for="item in form.reportWay !== 6
										? [
												{
													label: $t('calling.eliminateWayDiscarded'),
													value: 1,
												},
												{ label: $t('calling.eliminateWayNext'), value: 2 },
												{ label: $t('calling.eliminateWayEnd'), value: 3 },
												{ label: '移动到N位', value: 4 },
												{ label: '第N位插1', value: 5 },
										  ]
										: [
												{
													label: $t('calling.eliminateWayDiscarded'),
													value: 1,
												},
												{ label: $t('calling.eliminateWayEnd'), value: 3 },
												{ label: '移动到N位', value: 4 },
												{ label: '第N位插1', value: 5 },
										  ]"
									:key="item.value"
									:label="item.label"
									:value="item.value"
								/>
							</el-select>
						</el-form-item>
					</el-col>
					<!-- 移动到N位 -->
					<el-col :span="11" v-if="form.eliminateWay == '4'">
						<el-form-item label="N位置值">
							<el-input type="Number" v-model="form.moveNum"></el-input>
						</el-form-item>
					</el-col>
					<!-- 插入位置 -->
					<el-col :span="11" v-if="form.eliminateWay == '5'">
						<el-form-item label="N位">
							<el-input type="number" min="0" v-model="form.skipNum"></el-input>
						</el-form-item>
					</el-col>
					<!-- 复诊处置 -->
					<el-col :span="20">
						<el-form-item label="复诊处置" prop="replayWay ">
							<el-select
								v-model="form.replayWay"
								:placeholder="$t('calling.eliminateWay')"
							>
								<el-option
									v-for="item in [
										{ label: '移至末尾', value: 1 },
										{ label: '第N位插1', value: 2 },
									]"
									:key="item.value"
									:label="item.label"
									:value="item.value"
								/>
							</el-select>
						</el-form-item>
					</el-col>
					<!-- 插入位置 -->
					<el-col :span="11" v-if="form.replayWay == '2'">
						<el-form-item label="N位">
							<el-input type="number" min="0" v-model="form.skipNum"></el-input>
						</el-form-item>
					</el-col>
					<!-- 超时 -->
					<el-col :span="14">
						<el-form-item
							label="超时移出队列"
							prop="isTimeoutRemove"
							label-width="110px"
						>
							<el-radio-group v-model="form.isTimeoutRemove">
								<el-radio
									v-for="item in [
										{ label: '是', value: 1 },
										{ label: '否', value: 2 },
									]"
									:key="item.value"
									:label="item.value"
									>{{ item.label }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
					<el-col :span="10">
						<el-form-item label="超时时间">
							<el-input-number
								v-model="form.removeTime"
								:min="1"
								label="min"
							></el-input-number>
							min
						</el-form-item>
					</el-col>
					<!-- 当日未处理号码 -->
					<el-col :span="16">
						<el-form-item
							label-width="120px"
							:label="$t('calling.todayNotHandleWay')"
							prop="todayNotHandleWay"
						>
							<el-radio-group v-model="form.todayNotHandleWay">
								<el-radio
									v-for="dict in [
										{ label: $t('calling.empty'), value: 1 },
										{ label: $t('calling.retain'), value: 2 },
										{ label: $t('calling.moveAppointment'), value: 3 },
									]"
									:key="dict.value"
									:label="dict.value"
									>{{ dict.label }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
					<el-col :span="16">
						<el-form-item label="叫号模式">
							<el-select v-model="form.callMode">
								<el-option
									v-for="item in [
										{ label: '正常叫号', value: 1 },
										{ label: '交替叫号', value: 2 },
									]"
									:key="item.value"
									:label="item.label"
									:value="item.value"
								>
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<!-- TODO:叫号顺序 -->
					<el-col :span="24">
						<el-form-item label="叫号顺序" v-if="form.callMode == 2">
							<el-select
								v-model="form.alternateCallList[0].callStatus"
								style="width:15%"
								@change="$forceUpdate()"
							>
								<el-option
									v-for="item in queueStatusOptions"
									:key="item.value"
									:label="item.label"
									:value="parseInt(item.value)"
								>
								</el-option>
							</el-select>
							<el-input
								v-model="form.alternateCallList[0].num"
								style="width:7%"
								type="number"
								@input="$forceUpdate()"
							></el-input>

							<span>></span>
							<el-select
								v-model="form.alternateCallList[1].callStatus"
								style="width:15%"
								@change="$forceUpdate()"
							>
								<el-option
									v-for="item in queueStatusOptions"
									:key="item.value"
									:label="item.label"
									:value="parseInt(item.value)"
								>
								</el-option>
							</el-select>
							<el-input
								v-model="form.alternateCallList[1].num"
								type="number"
								style="width:7%"
								@input="$forceUpdate()"
							></el-input>
							<span>></span>
							<el-select
								v-model="form.alternateCallList[2].callStatus"
								style="width:15%"
								@change="$forceUpdate()"
							>
								<el-option
									v-for="item in queueStatusOptions"
									:key="item.value"
									:label="item.label"
									:value="parseInt(item.value)"
								>
								</el-option>
							</el-select>
							<el-input
								v-model="form.alternateCallList[2].num"
								style="width:7%"
								type="number"
								@input="$forceUpdate()"
							></el-input>
						</el-form-item>
					</el-col>
					<!-- <el-col :span="18">
					           <el-form-item :label="$t('calling.dataSource')" prop="dataSource">
					             <el-radio-group v-model="form.dataType">
					               <el-radio
					                   v-for="dict in [{label:$t('licalhostData'),value:1},{label:$t('thirdData'),value:2},{label:$t('hybridData'),value:3}]"
					                   :key="dict.value"
					                   :label="dict.value"
					               >{{ dict.label }}
					               </el-radio>
					             </el-radio-group>
					           </el-form-item>
					         </el-col>
					         <el-col v-if="form.dataType === 2||form.dataType ===3" :span="8">
					           <el-form-item :label="$t('calling.dataSourceId')" prop="dataSoureId">
					             <el-select filterable v-model="form.dataSoureId" :placeholder="$t('calling.dataSourceId')"
					                        style="width: 100%;"
					             >
					               <el-option
					                   v-for="item in datasetList"
					                   :key="item.id"
					                   :label="item.name"
					                   :value="item.id"
					               />
					             </el-select>
					           </el-form-item>
					         </el-col>
					         <el-col v-if="form.dataType==3" :span="8">
					           <el-form-item :label="$t('calling.localhostDataNum')" prop="DatasetMaxNum">
					             <avue-input-number v-model="form.localhostDataNum" precision="0" controls-position :min-rows="0"/>
					           </el-form-item>
					         </el-col>
					         <el-col v-if="form.dataType==3" :span="8">
					           <el-form-item :label="$t('calling.thirdDataNum')" prop="DatasetMaxNum">
					             <avue-input-number v-model="form.thirdDataNum" precision="0" controls-position :min-rows="0"/>
					           </el-form-item>
					         </el-col>
					         <el-col>
					           <el-time-picker
					               is-range
					               v-model="value1"
					               range-separator="至"
					               start-placeholder="开始时间"
					               end-placeholder="结束时间"
					               placeholder="选择时间范围">
					           </el-time-picker>
					         </el-col> -->

					<el-col :span="24">
						<el-form-item :label="$t('equipment.remarks')" prop="remarks">
							<el-input
								v-model="form.remarks"
								type="textarea"
								:placeholder="$t('equipment.remarksInput')"
							/>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitFormBizInfoRule">{{
					$t('submitText')
				}}</el-button>
				<el-button @click="cancelBizInfoRule">{{ $t('cancelText') }}</el-button>
			</div>
		</el-dialog>
		<!--诊室规则新增修改-->
		<el-dialog
			:title="title"
			:visible.sync="openCounterRuleAdd"
			:modal-append-to-body="true"
			:append-to-body="true"
			:before-close="cancelCounterRule"
		>
			<el-form
				ref="counterRuleForm"
				:model="form"
				:rules="rules"
				label-width="90px"
			>
				<el-row>
					<!-- 开放数量 -->
					<el-col :span="10">
						<el-form-item :label="$t('calling.limitNumber')" prop="num">
							<el-input-number v-model="form.num" :min="0"></el-input-number>
							<span class="red">0表示不限制</span>
						</el-form-item>
					</el-col>
					<!-- 过号类型 -->
					<el-col :span="10">
						<el-form-item
							:label="$t('calling.eliminateStyle' + '')"
							prop="type"
						>
							<el-select
								v-model="form.type"
								:placeholder="$t('calling.styleInput')"
								style="width: 100%;"
							>
								<el-option
									v-for="item in [
										{ label: $t('calling.bizinfoAgreement'), value: '1' },
										{ label: $t('calling.eliminateWayDiscarded'), value: '2' },
										{ label: $t('calling.eliminateWayNext'), value: '3' },
										{ label: $t('calling.eliminateWayEnd'), value: '4' },
										{ label: '移动到N位', value: '5' },
										{ label: '第N位插1', value: '6' },
									]"
									:key="item.value"
									:label="item.label"
									:value="item.value"
								/>
							</el-select>
						</el-form-item>
						<el-form-item v-if="form.type === '5'" label="移到N位置">
							<el-input
								label="移动到N位置"
								type="number"
								v-model="form.moveNum"
							></el-input>
						</el-form-item>
						<el-form-item v-if="form.type === '6'" label="N位">
							<el-input
								label="N位"
								type="number"
								min="0"
								v-model="form.skipNum"
							></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="10">
						<el-form-item label="复诊处置" prop="replayWay ">
							<el-select
								v-model="form.replayWay"
								:placeholder="$t('calling.styleInput')"
								style="width: 100%;"
							>
								<el-option
									v-for="item in [
										{ label: '和科室一致', value: 0 },
										{ label: '移至末尾', value: 1 },
										{ label: '第N位插1', value: 2 },
									]"
									:key="item.value"
									:label="item.label"
									:value="item.value"
								/>
							</el-select>
						</el-form-item>
						<el-form-item v-if="form.replayWay === '2'" label="N位">
							<el-input
								label="N位"
								type="number"
								min="0"
								v-model="form.skipNum"
							></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="16">
						<el-form-item label="叫号模式">
							<el-select v-model="form.callMode">
								<el-option
									v-for="item in [
										{ label: '正常叫号', value: 1 },
										{ label: '交替叫号', value: 2 },
										{ label: '和科室一致', value: 3 },
									]"
									:key="item.value"
									:label="item.label"
									:value="item.value"
								>
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="是否启用诊室自定义票号" label-width="190px">
							<el-radio-group v-model="form.isCustomTicket">
								<el-radio
									v-for="dict in [
										{ label: '启用', value: 1 },
										{ label: '禁用', value: 2 },
									]"
									:key="dict.value"
									:label="dict.value"
									>{{ dict.label }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item
							style="width: 60%"
							:label="$t('calling.ticketStyle')"
							prop="ticketStyle"
						>
							<el-select
								v-model="form.ticketStyle"
								:placeholder="$t('calling.ticketStyle')"
								style="width: 100%;"
							>
								<el-option
									v-for="item in ticketStyleList"
									:key="item.value"
									:label="item.label"
									:value="item.value"
								/>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item
							:label="$t('calling.ticketFormat')"
							prop="ticketFormat"
						>
							<el-input
								style="width: 35%"
								v-model="form.ticketHead"
								:placeholder="$t('calling.ticketHead')"
							>
							</el-input>
							<el-tag style="width:30%" type="info">
								{{
									ticketStyleList[form.ticketStyle - 1] == null
										? null
										: ticketStyleList[form.ticketStyle - 1].label
								}}
							</el-tag>
							<!--              <input type="submit" style="border-right: 0px" value="Submit" />-->
							<el-input
								style="width: 35%;"
								v-model="form.ticketEnd"
								:placeholder="$t('calling.ticketEnd')"
							></el-input>
						</el-form-item>
					</el-col>
					<!-- TODO:叫号顺序 -->
					<el-col :span="24">
						<el-form-item label="叫号顺序" v-if="form.callMode === 2">
							<el-select
								v-model="form.alternateCallList[0].callStatus"
								style="width:15%"
							>
								<el-option
									v-for="item in queueStatusOptions"
									:key="item.value"
									:label="item.label"
									:value="parseInt(item.value)"
								>
								</el-option>
							</el-select>
							<el-input
								v-model="form.alternateCallList[0].num"
								style="width:7%"
								type="number"
							></el-input>
							<span>></span>
							<el-select
								v-model="form.alternateCallList[1].callStatus"
								style="width:15%"
							>
								<el-option
									v-for="item in queueStatusOptions"
									:key="item.value"
									:label="item.label"
									:value="parseInt(item.value)"
								>
								</el-option>
							</el-select>
							<el-input
								v-model="form.alternateCallList[1].num"
								type="number"
								style="width:7%"
							></el-input>
							<span>></span>
							<el-select
								v-model="form.alternateCallList[2].callStatus"
								style="width:15%"
							>
								<el-option
									v-for="item in queueStatusOptions"
									:key="item.value"
									:label="item.label"
									:value="parseInt(item.value)"
								>
								</el-option>
							</el-select>
							<el-input
								v-model="form.alternateCallList[2].num"
								style="width:7%"
								type="number"
							></el-input>
						</el-form-item>
					</el-col>
					<!-- 状态 -->
					<el-col :span="10">
						<el-form-item :label="$t('program.status')">
							<el-radio-group v-model="form.status">
								<el-radio
									v-for="dict in [
										{ label: $t('calling.bizinfoRuleStatusEnable'), value: 0 },
										{ label: $t('calling.bizinfoRuleStatusDisable'), value: 1 },
									]"
									:key="dict.value"
									:label="dict.value"
									>{{ dict.label }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitFormCountRule">{{
					$t('submitText')
				}}</el-button>
				<el-button @click="cancelCounterRule">{{ $t('cancelText') }}</el-button>
			</div>
		</el-dialog>
		<!-- 添加或修改门诊管理对话框 -->
		<el-dialog
			:title="title"
			:visible.sync="open"
			:modal-append-to-body="true"
			:append-to-body="true"
			:close-on-click-modal="false"
		>
			<el-form
				ref="BizinfoForm"
				:model="form"
				:rules="rules"
				label-width="90px"
			>
				<el-row>
					<el-col :span="12">
						<el-form-item :label="$t('calling.name')" prop="name">
							<el-input
								v-model="form.name"
								:placeholder="$t('calling.nameInput')"
							/>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item :label="$t('calling.alias')" prop="alias">
							<el-input
								v-model="form.alias"
								:placeholder="$t('calling.aliasInput')"
							/>
						</el-form-item>
					</el-col>
					<!-- <el-col :span="12">
            <el-form-item :label="$t('calling.style')" prop="type">
              <el-select v-model="form.type" :placeholder="$t('calling.styleInput')">
                <el-option
                  v-for="dict in typeOptions"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col> -->
					<el-col :span="12">
						<el-form-item :label="$t('calling.department')" prop="deptId">
							<treeselect
								v-model="form.deptId"
								@input="inputSelect"
								:options="deptOptions"
								:normalizer="normalizer"
								:default-expand-level="2"
								:placeholder="$t('calling.departmentInput')"
							/>
						</el-form-item>
					</el-col>
					<!-- <el-col :span="24">
            <el-form-item prop="deviceCodes">
              <span slot="label">
                {{ $t('equipment.identification') }}
                <el-tooltip :content="$t('calling.identificationContent')" placement="top">
                  <i class="el-icon-question" />
                </el-tooltip>
              </span>
              <el-input v-model="form.deviceCodes" :placeholder="$t('calling.identificationInput')" />
            </el-form-item>
          </el-col> -->
					<!--<el-col :span="12">
            <el-form-item :label="$t('program.status')">
              <el-radio-group v-model="form.status">
                <el-radio
                  v-for="dict in statusOptions"
                  :key="dict.value"
                  :label="dict.value"
                >{{dict.label}}
                </el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>-->
					<el-col :span="24">
						<el-form-item :label="$t('calling.synopsis')">
							<el-input
								v-model="form.introduce"
								type="textarea"
								:placeholder="$t('calling.synopsisInput')"
							/>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitForm">{{
					$t('submitText')
				}}</el-button>
				<el-button @click="cancel">{{ $t('cancelText') }}</el-button>
			</div>
		</el-dialog>
		<!-- 添加或修改诊室管理对话框 -->
		<el-dialog
			:title="title"
			:visible.sync="counterOpen"
			:modal-append-to-body="true"
			:append-to-body="true"
		>
			<el-form
				ref="counterForm"
				:model="form"
				:rules="rules"
				label-width="90px"
			>
				<el-row>
					<el-col :span="12">
						<el-form-item :label="$t('calling.clinicName')" prop="name">
							<el-input
								v-model="form.name"
								:placeholder="$t('calling.clinicNameInput')"
							/>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item :label="$t('calling.clinicAlias')" prop="alias">
							<el-input
								v-model="form.alias"
								:placeholder="$t('calling.clinicAliasInput')"
							/>
						</el-form-item>
					</el-col>
					<el-col :span="12" style="height:120px">
						<el-form-item :label="$t('calling.outpatient')" prop="bizinfoIds">
							<el-select
								filterable
								v-model="form.bizinfoIds"
								multiple
								multiple-limit="1"
								:placeholder="$t('calling.outpatientInput')"
							>
								<el-option
									v-for="item in bizinfoOptions"
									:key="item.id"
									:label="item.name"
									:value="item.id"
								/>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12" style="height:120px">
						<el-form-item :label="$t('calling.accessMode')" prop="mode">
							<el-select
								v-model="form.mode"
								:placeholder="$t('calling.accessModeSelect')"
							>
								<el-option
									key="ads"
									:label="$t('calling.accessModeSelect1')"
									value="ads"
								/>
								<!-- <el-option key="led" :label="$t('calling.accessModeSelect2')" value="led" /> -->
							</el-select>
						</el-form-item>
					</el-col>
					<el-col v-if="form.mode == 'ads'" :span="12">
						<el-form-item label="播报设备" prop="deviceCode">
							<el-select
								v-model="form.deviceCode"
								placeholder="请选择"
								multiple
								filterable
							>
								<el-option
									v-for="item in deviceList"
									:key="item.code"
									:label="item.name"
									:value="item.code"
								>
								</el-option>
							</el-select>
							<!-- <el-input
								v-model="form.deviceCode"
								:placeholder="$t('equipment.identificationInput')"
							/> -->
						</el-form-item>
					</el-col>
					<el-col v-if="form.mode == 'ads'" :span="12">
						<el-form-item
							:label="$t('equipment.identification1')"
							prop="callCode"
						>
							<el-select
								v-model="form.callCode"
								placeholder="请选择"
								filterable
								clearable
							>
								<el-option
									v-for="item in deviceList"
									:key="item.code"
									:label="item.name"
									:value="item.code"
								>
								</el-option>
							</el-select>
							<!-- <el-input
								v-model="form.callCode"
								:placeholder="$t('equipment.identificationInput1')"
							/> -->
						</el-form-item>
					</el-col>
					<el-col v-if="form.mode == 'led'" :span="12">
						<el-form-item :label="$t('calling.controlCardType')">
							<el-select
								v-model="form.cardType"
								:placeholder="$t('calling.controlCardTypeSelect')"
								clearable
								size="small"
							>
								<el-option
									v-for="dict in cardTpeOptions"
									:key="dict.value"
									:label="dict.label"
									:value="dict.value"
								/>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col v-if="form.mode == 'led'" :span="12">
						<el-form-item :label="$t('calling.cardAddress')" prop="cardAddr">
							<el-input
								v-model="form.cardAddr"
								:placeholder="$t('calling.cardAddressInput')"
							/>
						</el-form-item>
					</el-col>
					<el-col v-if="form.mode == 'led'" :span="12">
						<el-form-item :label="$t('calling.cardPort')" prop="cardPort">
							<el-input-number
								v-model="form.cardPort"
								controls-position="right"
								:min="0"
							/>
						</el-form-item>
					</el-col>
					<!-- <el-col :span="12">
            <el-form-item :label="$t('calling.autoLogin')">
              <el-radio-group v-model="form.autoLogin">
                <el-radio
                  v-for="dict in autoLoginOptions"
                  :key="dict.value"
                  :label="dict.value"
                >{{ dict.label }}
                </el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col> -->
					<el-col v-if="form.mode == 'ads'" :span="12">
						<el-form-item label="显示设备" prop="bindCode">
							<el-select
								v-model="form.bindCode"
								placeholder="请选择"
								multiple
								filterable
							>
								<el-option
									v-for="item in deviceList"
									:key="item.code"
									:label="item.name"
									:value="item.code"
								>
								</el-option>
							</el-select>
							<!-- <el-input
								v-model="form.deviceCode"
								:placeholder="$t('equipment.identificationInput')"
							/> -->
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item :label="$t('program.status')">
							<el-radio-group v-model="form.status">
								<el-radio
									v-for="dict in statusOptions"
									:key="dict.value"
									:label="dict.value"
									>{{ dict.label }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitCounterForm">{{
					$t('submitText')
				}}</el-button>
				<el-button @click="cancel">{{ $t('cancelText') }}</el-button>
			</div>
		</el-dialog>
	</el-container>
</template>

<script>
import SelectAll from '@/components/selectAll'
import {
	listBizinfo,
	getBizinfo,
	delBizinfo,
	addBizinfo,
	editBizinfo,
	updateCache,
	exportBizinfo,
	listBizinfoRule,
	selectCounterRuleList,
	delBizinfoRule,
	editBizinfoRule,
	getBizinfoRule,
	addBizinfoRule,
	editBizinfoRuleStatus,
	listBizinfoRuleInterval,
	businessList,
} from '@/api/qbs/bizinfo'
import {
	listCounter,
	getCounter,
	delCounter,
	addCounter,
	editCounter,
	updateCounterCache,
	exportCounter,
	listCounterRule,
	getCounterRule,
	addCounterRule,
	editCounterRule,
	delCounterRule,
	editCounterRuleStatus,
	editCounterRuleList,
	addBatchCounterRule,
} from '@/api/qbs/counter'
import { listDevice } from '@/api/ips/device'
import { getDatasetAll } from '@/api/system/dataset'
import { deptTree } from '@/api/system/dept'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import dayjs from 'dayjs'
import ScheduleGroupItem from './ScheduleGroupItem'

const DAY_MAX_TIME = 24 * 60 * 60 * 1000
export default {
	name: 'Bizinfo',
	components: {
		Treeselect,
		ScheduleGroupItem,
		SelectAll,
	},
	data() {
		// 判断诊室的开放数量之和是否大于科室的最大数数量
		var vaitMaxnumber = (rule, value, callback) => {
			// 个诊室的数量合
			var numTotal = 0
			this.counterNumList.forEach((item) => {
				numTotal += parseInt(item.num)
			})
			if (numTotal > this.form.num) {
				callback(new Error('诊室数量之和不能大于科室开放数量'))
			} else {
				callback()
			}
		}
		// 判断数据源的开放数量之和是否大于科室的最大数数量
		var vaitDataMaxnumber = (rule, value, callback) => {
			if (this.form.localhostDataNum + this.form.thirdDataNum > this.form.num) {
				callback(new Error('数据源数量之和不能大于科室开放数量'))
			} else {
				callback()
			}
		}
		return {
			today: dayjs()
				.startOf('day')
				.valueOf(),
			//重复区时间间集合
			intervalTimes: [],
			ticketStyleList: [
				{ label: '1,2,3....', value: 1 },
				{ label: '01,02,03....', value: 2 },
				{ label: '001,002,003....', value: 3 },
				{ label: 'a,b,c....', value: 4 },
			],
			// 遮罩层
			loading: true,
			addtitleName: '添加门诊规则',
			edittitleName: '修改门诊',
			// 选中数组
			ids: [],
			// 非单个禁用
			single: true,
			// 非多个禁用
			multiple: true,
			// 总条数
			total: 0,
			// 门诊管理表格数据
			bizinfoList: [],
			// 弹出层标题
			title: '',
			// 是否显示弹出层
			open: false,
			// 日期范围
			dateRange: [],
			// 数据源列表
			datasetList: [],
			// 数据源名称
			datasetName: null,
			//重复判断依据
			repeatJudge: [],
			//重复周期
			repeatCycle: [],
			// 科室的诊室的规则的最大数量
			counterNumList: [],
			// 机构名称树选项
			deptOptions: undefined,
			// 门诊规则弹出层
			openBizInfoRule: false,
			// 诊室规则弹出层
			openCounterRuleAdd: false,
			// 门诊规则数据
			bizinfoRuleList: [],
			// 类型字典
			// typeOptions: [{ id: 64, label: '分诊' }], // 状态字典
			typeOptions: [], // 状态字典
			statusOptions: [], // 查询参数
			isAutoReportOptions: [], // 查询参数
			bizinfoRuleStatusOptions: [], // 查询参数
			reportWayOptions: [], // 查询参数
			queueStatusOptions: [], // 队列字典
			digitBroadcastOption: [], // 数字播报模式
			queryParams: {
				current: 1,
				size: 10,
				name: undefined,
				type: undefined,
				status: undefined,
				createTime: undefined,
			},
			// 显示搜索条件
			showSearch: true,
			// 表单参数
			form: {},
			ttt: true,
			// 诊室规则弹出框
			openCounterRule: false,
			counterRuleList: {},
			cardTpeOptions: [],
			isDefaultOptions: [],
			autoLoginOptions: [],
			deviceList: [],
			bizinfoOptions: [],
			deleteIds: [],
			exportIds: [],
			openBizInfoRuleAdd: false,
			// 表单校验
			rules: {
				num: [
					{
						required: true,
						message: this.$t('calling.numtSuccess'),
						trigger: 'change',
					},
				],
				isAutoReport: [
					{
						required: true,
						message: this.$t('calling.isAutoReportSuccess'),
						trigger: 'blur',
					},
				],
				name: [
					{ required: true, message: this.$t('nameEmpty'), trigger: 'blur' },
				],
				type: [
					{ required: true, message: this.$t('styleEmpty'), trigger: 'blur' },
				],
				deptId: [
					{
						required: true,
						message: this.$t('calling.departmentEmpty'),
						trigger: 'change',
					},
				],
				maxNum: [{ validator: vaitMaxnumber, trigger: 'blur' }],
				DatasetMaxNum: [{ validator: vaitDataMaxnumber, trigger: 'blur' }],
				num: [
					{
						required: true,
						message: this.$t('calling.numtSuccess'),
						trigger: 'blur',
					},
				],
				name: [
					{ required: true, message: this.$t('nameEmpty'), trigger: 'blur' },
				],
				bizinfoIds: [
					{ required: true, message: '所属门诊不能为空', trigger: 'change' },
				],
				mode: [
					{ required: true, message: '接入方式不能为空', trigger: 'blur' },
				],
				bizinfoIdList: [
					{ required: true, message: '选择的科室不能为空', trigger: 'blur' },
				],
			},
			// 是否是统一规则
			isuniformRules: false,
		}
	},
	async created() {
		this.getBizInfoRuleList(this.bizinfoId)
		this.getBizinfoList()
		this.getList()
		this.getDeptTree()
		const { data } = await listDevice({ size: 10000 })
		this.deviceList = data
		this.getDicts('bizinfo_type').then((response) => {
			this.typeOptions = response.data
		})
		this.getDicts('status').then((response) => {
			this.statusOptions = response.data
		})
		this.getDicts('is_auto_report').then((response) => {
			this.isAutoReportOptions = response.data
		})
		this.getDicts('bizinfo_rule_status').then((response) => {
			this.bizinfoRuleStatusOptions = response.data
		})
		this.getDicts('report_way').then((response) => {
			this.reportWayOptions = response.data
		})
		this.getDicts('yes_no').then((response) => {
			this.autoLoginOptions = response.data
		})
		this.getDicts('card_type').then((response) => {
			this.cardTpeOptions = response.data
		})
		this.getDicts('isDefault').then((response) => {
			this.isDefaultOptions = response.data
		})
		this.getDicts('queue_status').then((response) => {
			this.queueStatusOptions = response.data
			console.log(`response.data`, response.data)
		})

		this.form.alternateCallList = []
		this.form.alternateCallList.push(
			{
				type: 1,
				callStatus: 1,
				sort: 1,
				num: 1,
			},
			{
				type: 1,
				callStatus: 2,
				sort: 2,
				num: 2,
			},
			{
				type: 1,
				callStatus: 3,
				sort: 3,
				num: 3,
			}
		)
	},
	watch: {
		openBizInfoRuleAdd(val) {
			if (!val) {
				console.log(`val`, val)
				this.isuniformRules = false
			}
		},
	},
	methods: {
		uniformRules() {
			this.reset()
			this.getAllDataset()
			this.title = '统一规则新增'
			this.form.status = 0
			this.form.num = 1000
			//重复判断依据
			if (this.form.repeatJudge != '' && this.form.repeatJudge != null) {
				this.repeatJudge = this.form.repeatJudge.split(',')
			}
			//重复周期
			if (this.form.repeatCycle != '' && this.form.repeatCycle != null) {
				this.repeatCycle = this.form.repeatCycle.split(',')
			}
			if (this.form.skipHoliday != null) {
				this.form.skipHoliday = this.form.skipHoliday == 'true' ? true : false
			}
			this.isuniformRules = true
			this.openBizInfoRuleAdd = true
			console.log(`this.form`, this.form)
		},
		inputSelect() {
			this.$refs.form.validateField('deptId')
		},
		/** 查询门诊管理列表 */
		getList() {
			this.loading = true
			businessList(this.addDateRange(this.queryParams, this.dateRange)).then(
				(response) => {
					this.bizinfoList = response.data
					this.total = response.total
					this.loading = false
				}
			)
		},
		// 获取每行的数据设置key值
		getRowKeys(row) {
			return row.id + row.name
		},
		/** 查询机构名称下拉树结构 */
		getDeptTree() {
			deptTree().then((response) => {
				if (response.data && response.data.length > 0) {
					this.deptOptions = this.handleTree(
						response.data,
						'deptId',
						'parentId',
						'children',
						response.data[0].parentId
					)
				} else {
					this.deptOption = []
				}
			})
		},
		/** 转换机构数据结构 */
		normalizer(node) {
			if (node.children && !node.children.length) {
				delete node.children
			}
			return {
				id: node.deptId,
				label: node.name,
				children: node.children,
			}
		},
		// 类型字典翻译
		typeFormat(row, column) {
			if (row.type === '0') {
				return this.$t('calling.triage')
			}
			// return this.selectDictLabel(this.typeOptions, row.type)
		},
		// 状态字典翻译
		statusFormat(row, column) {
			return this.selectDictLabel(this.statusOptions, row.status)
		},
		isAutoReportFormat(row, column) {
			return this.selectDictLabel(this.isAutoReportOptions, row.isAutoReport)
		},
		statusRuleFormat(row, column) {
			return this.selectDictLabel(this.bizinfoRuleStatusOptions, row.status)
		},
		reportWayFormat(row, column) {
			return this.selectDictLabel(this.reportWayOptions, row.reportWay)
		},
		// 取消按钮
		cancel() {
			this.open = false
			this.counterOpen = false
			this.reset()
		},
		// 新增规则窗口取消按钮
		async cancelBizInfoRule() {
			this.openBizInfoRuleAdd = false
			this.reset()
		},
		// 表单重置
		reset() {
			this.repeatCycle = ['1', '2', '3', '4', '5', '6', '7']
			this.repeatJudge = []
			this.intervalTimes = []
			this.form = {
				skipHoliday: false,
				id: undefined,
				name: undefined,
				alias: undefined,
				type: undefined,
				introduce: undefined,
				deptId: undefined,
				status: 0,
				isAutoReport: 1,
				isReport: 2,
				eliminateWay: 1,
				todayNotHandleWay: 1,
				isDefault: 0,
				mode: 'ads',
				callMode: 1,
				isFollowStaff: 2,
				isCustomTicket: 1,
				bizinfoIdList: [],
			}
			this.form.alternateCallList = []
			this.form.alternateCallList.push(
				{
					type: 1,
					callStatus: 1,
					sort: 1,
					num: 1,
				},
				{
					type: 1,
					callStatus: 2,
					sort: 2,
					num: 2,
				},
				{
					type: 1,
					callStatus: 3,
					sort: 3,
					num: 3,
				}
			)
			// this.resetForm('form')
		},
		/** 搜索按钮操作 */
		handleQuery() {
			this.queryParams.current = 1
			this.getList()
		},
		/** 重置按钮操作 */
		resetQuery() {
			this.dateRange = []
			this.resetForm('queryForm')

			this.handleQuery()
		},
		/** 规则列表 */
		handleBizInfoRule(row) {
			this.reset()
			if (row.counterList) {
				const id = row.id || this.ids
				listBizinfoRule({ bizinfoId: id }).then((response) => {
					this.bizinfoRuleList = response.data
					this.loading = false
					this.openBizInfoRule = true
					this.title = this.$t('calling.bizinfoRules')
					this.bizinfoId = id
				})
			} else {
				const id = row.id || this.ids
				listCounterRule({ counterId: id }).then((response) => {
					this.counterRuleList = response.data
					this.loading = false
					this.openCounterRule = true
					this.title = this.$t('calling.bizinfoRules')
					this.counterId = id
				})
			}
		},
		/** 规则列表刷新按钮 */
		getBizInfoRuleList(id) {
			this.loading = true
			listBizinfoRule({ bizinfoId: id }).then((response) => {
				this.bizinfoRuleList = response.data
				this.loading = false
			})
		},
		getAllDataset() {
			getDatasetAll().then((response) => {
				this.datasetList = response.data
			})
		},
		/** 根据科室id查找诊室的规则的最大数量 */
		selectCounterRuleList(id) {
			selectCounterRuleList(id).then((response) => {
				this.counterNumList = response.data
			})
		},
		/** 更新规则状态 */
		handleBizInfoRuleStatusEdit(row) {
			// eslint-disable-next-line eqeqeq
			const status = row.status == 0 ? '禁用' : '启用'
			this.$confirm(
				this.$t('calling.is') + status + this.$t(),
				this.$t('warning'),
				{
					confirmButtonText: this.$t('submitText'),
					cancelButtonText: this.$t('cancelText'),
					type: 'warning',
				}
			)
				.then(function() {
					// eslint-disable-next-line eqeqeq
					return editBizinfoRuleStatus(
						row.id,
						row.bizinfoId,
						row.status == 0 ? 1 : 0
					)
				})
				.then(() => {
					this.getBizInfoRuleList(this.bizinfoId)
					this.msgSuccess(this.$t('calling.updateSuccess'))
				})
				.catch(function() {})
		},
		/** 删除按钮操作 */
		handleBizInfoRuleDel(row) {
			const ids = row.id || this.ids
			this.$confirm(
				this.$t('calling.deleteRulesNumber') +
					ids +
					this.$t('equipment.deleteEquipment2'),
				this.$t('warning'),
				{
					confirmButtonText: this.$t('submitText'),
					cancelButtonText: this.$t('cancelText'),
					type: 'warning',
				}
			)
				.then(function() {
					return delBizinfoRule(ids)
				})
				.then(() => {
					this.getBizInfoRuleList(this.bizinfoId)
					this.msgSuccess(this.$t('deleteSuccess'))
				})
				.catch(function() {})
		},
		/** 删除按钮操作 */
		handleCounterRuleDel(row) {
			const ids = row.id || this.ids
			this.$confirm(
				this.$t('calling.deleteRulesNumber') +
					ids +
					this.$t('equipment.deleteEquipment2'),
				this.$t('warning'),
				{
					confirmButtonText: this.$t('submitText'),
					cancelButtonText: this.$t('cancelText'),
					type: 'warning',
				}
			)
				.then(function() {
					return delCounterRule(ids)
				})
				.then(() => {
					this.getCounterRuleList(this.counterId)
					this.msgSuccess(this.$t('deleteSuccess'))
				})
				.catch(function() {})
		},
		/** 修改门诊规则按钮操作 */
		async handleBizInfoRuleEdit(row) {
			this.reset()
			await this.selectCounterRuleList(this.bizinfoId)
			this.getAllDataset()
			const id = row.id || this.ids
			getBizinfoRule(id).then((response) => {
				this.form = response.data
				if (!this.form.alternateCallList.length) {
					this.form.alternateCallList = []
					this.form.alternateCallList.push(
						{
							type: 1,
							callStatus: 1,
							sort: 1,
							num: 1,
						},
						{
							type: 1,
							callStatus: 2,
							sort: 2,
							num: 2,
						},
						{
							type: 1,
							callStatus: 3,
							sort: 3,
							num: 3,
						}
					)
				}
				//重复判断依据
				if (this.form.repeatJudge != '' && this.form.repeatJudge != null) {
					this.repeatJudge = this.form.repeatJudge.split(',')
				}
				//重复周期
				if (this.form.repeatCycle != '' && this.form.repeatCycle != null) {
					this.repeatCycle = this.form.repeatCycle.split(',')
				}
				if (this.form.skipHoliday != null) {
					this.form.skipHoliday = this.form.skipHoliday == 'true' ? true : false
				}
				this.openBizInfoRuleAdd = true
				console.log(`this.form edit`, this.form)
				this.title = this.$t('calling.editbizinfoRules')
			})
			listBizinfoRuleInterval(id).then((response) => {
				this.intervalTimes = []
				response.data.forEach((val) => {
					var times = {}
					times.start = val.startTime
					times.end = val.endTime
					this.intervalTimes.push(times)
				})
				// this.value1.push(response.data)
			})
			this.reset()
		},

		addItem(index) {
			const currentItem = this.intervalTimes[index]
			const nextItem = this.intervalTimes[index + 1]
			const newItem = {
				start: currentItem ? currentItem.end : 0,
				end: nextItem ? nextItem.start : DAY_MAX_TIME,
			}
			this.intervalTimes.splice(index + 1, 0, newItem)
		},
		deleteItem(index) {
			this.intervalTimes.splice(index, 1)
		},
		isAddable(index) {
			const currentItem = this.intervalTimes[index]
			const nextItem = this.intervalTimes[index + 1]
			if (index < 0) {
				// 顶部加号可用
				return this.intervalTimes[0] ? this.intervalTimes[0].start > 0 : true
			}
			if (index >= this.intervalTimes.length - 1) {
				// 最后一项
				return currentItem.end < 24 * 60 * 60 * 1000 - 1000
			}
			// 非最后一项
			return nextItem.start - currentItem.end > 0
		},
		getMaxTime(index) {
			const nextItem = this.intervalTimes[index + 1]
			return nextItem ? nextItem.start : DAY_MAX_TIME
		},
		getMinTime(index) {
			const lastItem = this.intervalTimes[index - 1]
			return lastItem ? lastItem.end : 0
		},
		/** 提交按钮 */
		submitFormBizInfoRule: function() {
			console.log('进入函数---submitFormBizInfoRule', this.form)
			// eslint-disable-next-line eqeqeq
			if (this.form.isAutoReport == 1 && !this.form.reportWay) {
				this.msgError(this.$t('calling.reportWaySuccess'))
				return false
			}
			this.$refs['form'].validate((valid) => {
				console.log('进入函数---validate')
				if (this.repeatJudge != null) {
					this.form.repeatJudge = this.repeatJudge.join()
				}
				if (this.repeatCycle != null) {
					this.form.repeatCycle = this.repeatCycle.join()
				}
				console.log(`valids`, valid)
				if (valid) {
					console.log(`this.form.bizinfoIdList`, this.form.bizinfoIdList)
					let bizinfoRuleIntervalTimeList = []
					this.intervalTimes.forEach((item) => {
						if (item != null) {
							let interVal = {}
							interVal.bizinfoRuleId = this.form.id
							interVal.startTime = item.start
							interVal.endTime = item.end
							bizinfoRuleIntervalTimeList.push(interVal)
						}
					})
					this.form.bizinfoRuleIntervalTimeList = bizinfoRuleIntervalTimeList
					if (this.form.bizinfoIdList && this.form.bizinfoIdList.length) {
						addBatchCounterRule(this.form).then((response) => {
							if (response.code === 0) {
								this.msgSuccess('批量新增统一规则成功')
								this.openBizInfoRuleAdd = false
								this.isuniformRules = false
								this.reset()
								this.getBizInfoRuleList(this.bizinfoId)
							} else {
								this.msgError(response.msg)
							}
						})
					} else if (this.form.id !== undefined) {
						editBizinfoRule(this.form).then((response) => {
							if (response.code === 0) {
								editCounterRuleList(this.counterNumList).then((response) => {
									if (response.code === 0) {
										this.msgSuccess(this.$t('loginLog.changeSuccess'))
										this.openBizInfoRuleAdd = false
										this.getBizInfoRuleList(this.bizinfoId)
									} else {
										this.msgError(response.msg)
									}
								})
							} else {
								this.msgError(response.msg)
							}
						})
					} else {
						this.form.bizinfoId = this.bizinfoId
						addBizinfoRule(this.form).then((response) => {
							if (response.code === 0) {
								editCounterRuleList(this.counterNumList).then((response) => {
									if (response.code === 0) {
										this.msgSuccess(this.$t('addSuccess'))
										this.openBizInfoRuleAdd = false
										this.getBizInfoRuleList(this.bizinfoId)
									} else {
										this.msgError(response.msg)
									}
								})
							} else {
								this.msgError(response.msg)
							}
						})
					}
				}
			})
		},
		/** 新增门诊规则按钮操作 */
		handleBizInfoRuleAdd() {
			this.reset()
			this.selectCounterRuleList(this.bizinfoId)
			this.getAllDataset()
			this.openBizInfoRuleAdd = true
			this.title = this.$t('calling.addbizinfoRules')
			this.form.status = 0
			this.form.num = 1000
		},
		// 新增诊室规则按钮操作
		handleCounterRuleAdd() {
			this.reset()
			this.getCounterRuleList(this.counterId)
			this.getAllDataset()
			this.title = this.$t('calling.addbizinfoRules')
			this.form.status = 0
			this.form.num = 0
			this.openCounterRuleAdd = true
		},
		// 多选框选中数据
		handleSelectionChange(selection) {
			console.log(`<<<<2023年05月06日 16:37:48>>>>`, { selection: selection })
			this.ids = selection.map((item) => item.id)
			this.deleteIds = selection.map((item) => {
				return { id: item.id, type: item.counterList ? 'bizinfo' : 'counter' }
			})
			this.single = selection.length !== 1
			this.multiple = !selection.length
		},
		/** 新增按钮操作 */
		handleCommand(command) {
			if (command === 'first') {
				this.handleAdd('first')
			} else {
				this.handleAdd('second')
			}
		},

		async handleAdd(query) {
			this.reset()
			if (query === 'first') {
				this.open = true
				this.title = this.$t('calling.addTriage')
			} else {
				this.counterOpen = true
				// 因为是下拉框，没有分页，所以暂时把size 设置为10000
				const { data } = await listDevice({ size: 10000 })
				this.deviceList = data
				this.title = this.$t('calling.addClinnic')
			}
		},
		/** 修改按钮操作 */
		async handleEdit(row) {
			if (row.counterList) {
				this.reset()
				const id = row.id || this.ids
				getBizinfo(id).then((response) => {
					this.form = response.data
					this.open = true
					this.title = this.$t('calling.changeTriage')
				})
			} else {
				this.reset()
				const id = row.id || this.ids
				const { data } = await listDevice({ size: 10000 })
				this.deviceList = data
				getCounter(id).then((response) => {
					this.form = response.data
					this.form.bizinfoIds = this.form.bizinfoIds.split(',')
					if (this.form.deviceCode) {
						this.form.deviceCode = this.form.deviceCode.split(',')
					}
					if (this.form.bindCode) {
						this.form.bindCode = this.form.bindCode.split(',')
					}
					this.counterOpen = true
					this.title = this.$t('calling.changeClinnic')
				})
			}
		},
		selectAllChange(data) {
			console.log(`data`, data)
		},
		// 诊室新增取消按钮
		cancelCounterRule() {
			this.openCounterRuleAdd = false
			this.reset()
		},
		// 获取诊室规则列表
		getCounterRuleList(id) {
			this.loading = true
			listCounterRule({ counterId: id }).then((response) => {
				this.counterRuleList = response.data
				this.loading = false
			})
		},
		/** 更新缓存按钮操作 */
		handleCache(row) {
			updateCache().then((response) => {
				this.msgSuccess(this.$t('localUpdateSuccess'))
			})
		},
		/** 门诊提交按钮 */
		submitForm: function() {
			this.$refs['BizinfoForm'].validate((valid) => {
				if (valid) {
					if (this.form.id !== undefined) {
						editBizinfo(this.form).then((response) => {
							if (response.code === 0) {
								this.msgSuccess(this.$t('loginLog.changeSuccess'))
								this.open = false
								this.getBizinfoList()
								this.getList()
							} else {
								this.msgError(response.msg)
							}
						})
					} else {
						addBizinfo(this.form).then((response) => {
							if (response.code === 0) {
								this.msgSuccess(this.$t('addSuccess'))
								this.open = false
								this.getBizinfoList()
								this.getList()
							} else {
								this.msgError(response.msg)
							}
						})
					}
				}
			})
		},
		/**诊室 提交按钮 */
		submitCounterForm: function() {
			console.log(`submitCounterForm`)
			this.$refs['counterForm'].validate((valid) => {
				if (valid) {
					this.form.bizinfoNames = this.selectGetName(this.form.bizinfoIds)
					console.log(this.form.bizinfoIds)
					if (this.form.deviceCode) {
						this.form.deviceCode = this.form.deviceCode.join(',')
					}
					if (this.form.bindCode) {
						this.form.bindCode = this.form.bindCode.join(',')
					}
					if (Array.isArray(this.form.bizinfoIds)) {
						this.form.bizinfoIds = this.form.bizinfoIds.join()
					}
					if (this.form.id !== undefined) {
						editCounter(this.form).then((response) => {
							if (response.code === 0) {
								this.msgSuccess(this.$t('loginLog.changeSuccess'))
								this.counterOpen = false
								this.getList()
							} else {
								this.msgError(response.msg)
							}
						})
					} else {
						addCounter(this.form).then((response) => {
							if (response.code === 0) {
								this.msgSuccess(this.$t('addSuccess'))
								this.counterOpen = false
								this.getList()
							} else {
								this.msgError(response.msg)
							}
						})
					}
				}
			})
		},
		/** 提交按钮 */
		submitFormCountRule: function() {
			this.$refs['counterRuleForm'].validate((valid) => {
				if (valid) {
					if (this.form.id !== undefined) {
						// this.form.startTime = this.form.timeInterval[0]
						// this.form.finishTime = this.form.timeInterval[1]
						editCounterRule(this.form).then((response) => {
							if (response.code === 0) {
								this.msgSuccess(this.$t('loginLog.changeSuccess'))
								this.openCounterRuleAdd = false
								this.getCounterRuleList(this.counterId)
							} else {
								this.msgError(response.msg)
							}
						})
					} else {
						this.form = {
							counterId: this.counterId,
							type: this.form.type,
							num: this.form.num,
							status: this.form.status,
							// startTime: this.form.timeInterval[0],
							// finishTime: this.form.timeInterval[1],
							isDefault: 0,
						}
						addCounterRule(this.form).then((response) => {
							if (response.code === 0) {
								this.msgSuccess(this.$t('addSuccess'))
								this.openCounterRuleAdd = false
								this.getCounterRuleList(this.counterId)
							} else {
								this.msgError(response.msg)
							}
						})
					}
				}
			})
		},
		selectGetName(bizinfoIds) {
			// if(bizinfoIds)
			var bizinfoArr = []
			for (let i = 0; i < bizinfoIds.length; i++) {
				const obj = this.bizinfoOptions.find((item) => {
					return item.id === bizinfoIds[i]
				})
				this.$set(bizinfoArr, i, obj && obj.name)
			}
			// console.log('选择的门诊', bizinfoArr);
			return bizinfoArr.join()
		},
		// 获取门诊列表
		getBizinfoList() {
			listBizinfo({ current: 1, size: 1000 }).then((response) => {
				this.bizinfoOptions = response.data.map((item) => {
					item.id = item.id + ''
					return item
				})
			})
		},
		/** 诊室修改按钮操作 */
		handleCounterRuleEdit(row) {
			const id = row.id || this.ids
			getCounterRule(id).then(async (response) => {
				console.log(`getCounterRule`, response.data)
				this.reset()
				console.log(`this.form`, this.form)
				// 直接赋值会导致this.form.num的值出现错误，暂时没发现问题。只能先这么改
				Object.assign(this.form, response.data)
				// this.form = response.data
				this.form.alternateCallList = []
				this.form.alternateCallList.push(
					{
						type: 1,
						callStatus: 1,
						sort: 0,
						num: 1,
					},
					{
						type: 1,
						callStatus: 2,
						sort: 1,
						num: 2,
					},
					{
						type: 1,
						callStatus: 3,
						sort: 2,
						num: 3,
					}
				)
				this.title = this.$t('calling.changeClinnicRules')
				const dateTemp = []
				dateTemp.push(this.form.startTime)
				dateTemp.push(this.form.finishTime)
				this.$set(this.form, 'timeInterval', dateTemp)
				if (this.form.isDefault === 1) {
					this.form.isDefault = '1'
				} else {
					this.form.isDefault = '0'
				}
				this.openCounterRuleAdd = true
			})
		},
		/** 删除按钮操作 */
		handleDel(row) {
			if (!row.id) {
				let counterIds = [],
					bizIds = []
				this.deleteIds.forEach((item) => {
					if (item.type === 'counter') {
						counterIds.push(item.id)
					} else {
						bizIds.push(item.id)
					}
				})
				this.$confirm('是否确认删除选中的数据', this.$t('warning'), {
					confirmButtonText: this.$t('submitText'),
					cancelButtonText: this.$t('cancelText'),
					type: 'warning',
				}).then(async () => {
					bizIds.length && (await delBizinfo(bizIds.join(',')))
					counterIds.length && (await delCounter(counterIds.join(',')))
					this.getList()
					this.getBizinfoList()
					this.msgSuccess(this.$t('deleteSuccess'))
				})
			} else {
				const ids = row.id || this.ids
				this.$confirm(
					row.counterList
						? this.$t('calling.clinicNumberDelete')
						: this.$t('calling.deleteClinic') +
								ids +
								this.$t('equipment.deleteEquipment2'),
					this.$t('warning'),
					{
						confirmButtonText: this.$t('submitText'),
						cancelButtonText: this.$t('cancelText'),
						type: 'warning',
					}
				)
					.then(function() {
						return row.counterList ? delBizinfo(ids) : delCounter(ids)
					})
					.then(() => {
						this.getList()
						this.getBizinfoList()
						this.msgSuccess(this.$t('deleteSuccess'))
					})
					.catch(function() {})
			}
		},
		/** 导出按钮操作 */
		handleExport() {
			if (this.ids.length === 0) {
				this.msgWarning(this.$t('equipment.equipmentInput'))
				return
			}
			const queryParams = this.queryParams
			this.$confirm(
				this.$t('calling.exportAllNumberData'),
				this.$t('warning'),
				{
					confirmButtonText: this.$t('submitText'),
					cancelButtonText: this.$t('cancelText'),
					type: 'warning',
				}
			)
				.then(() => {
					let counterIds = [],
						bizIds = []
					this.deleteIds.forEach((item) => {
						if (item.type === 'counter') {
							counterIds.push(item.id)
						} else {
							bizIds.push(item.id)
						}
					})
					if (this.deleteIds.type === 'counter') {
						return exportCounter(queryParams, counterIds)
					} else {
						return exportBizinfo(queryParams, bizIds)
					}
				})
				.then((response) => {
					this.download(response.data)
				})
				.catch(function() {})
		},
	},
}
</script>
<style scoped>
.el-header,
.el-footer {
	/* background-color: #b3c0d1; */
	/* color: #333; */
	text-align: center;
	line-height: 60px;
}
</style>
